//
//  HistoryHeaderReusableView.m
//  quxiangtao
//
//  Created by HHuajiang on 2018/11/28.
//  Copyright © 2018 shanhaijin. All rights reserved.
//

#import "HistoryHeaderReusableView.h"

@implementation HistoryHeaderReusableView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        UILabel *label = [[UILabel alloc] init];
        label.textColor = Color333333;
        label.font = Font(24);
        label.text = @"历史搜索";
        [self addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(Margin);
            make.centerY.equalTo(self.mas_centerY);
        }];
        self.sectionLabel = label;
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"searchHistoryRemoveBG"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(deleteButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(20, 20));
            make.right.mas_equalTo(-Margin);
        }];
        self.deleteButton = button;
        
    }
    return self;
}

- (void)deleteButtonClick {
    if (self.deleteButtonClickBlock) {
        self.deleteButtonClickBlock();
    }
}
@end
